package models

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	OrderSn string `gorm:"type:char(36);not null;commit:'订单编号'"`
	Stock   int64  `gorm:"type:int;not null;commit:'库存'"`
	Amount  string `gorm:"type:decimal(10,2);not null;commit:'价格'"`
	Status  int64  `gorm:"type:int;not null;commit:'商品状态: 0-上架,1-下架'"`
	PayType int64  `gorm:"type:int;not null;commit:'商品状态: 0-微信,1-支付宝'"`
}
type OrderGood struct {
	Title string  `gorm:"type:varchar(150);not null;commit:'订单标题'"`
	Price float64 `gorm:"type:decimal(10,0);not null;commit:'订单价格'"`
	Stock int64   `gorm:"type:int;not null;commit:'订单库存'"`
	Image string  `gorm:"type:varchar(150);not null;commit:'订单图片'"`
}

func (o *Order) OrderAdd() error {
	return DB.Create(&o).Error
}
func (og *OrderGood) OrderGoodAdd() error {
	return DB.Create(&og).Error
}
